/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-请求处理层-基础支撑平台
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.basic.webapi.controller;

import com.taiping.cc.basic.webapi.query.HadoopTableData;
import com.taiping.cc.basic.webapi.constant.RequestParamType;
import com.taiping.cc.basic.webapi.query.QueryModel;
import com.taiping.cc.basic.webapi.query.SubmitModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "HBase-DML接口文档")
@RestController
@RequestMapping("/hadoop/db/dml")
public class HadoopDMLController {

    //region 查询数据

    /**
     * 查询数据
     */
    @ApiOperation(value = "查询数据", notes = "流年·公子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "tableName", value = "HBase表名", required = true, dataType = "String", paramType = RequestParamType.QUERY),
            @ApiImplicitParam(name = "rowKey", value = "唯一标识", required = true, dataType = "String", paramType = RequestParamType.QUERY)
    })
    @GetMapping(value = "/data/get")
    public HadoopTableData getDataFromHBase(@RequestParam(name = "tableName") String tn, @RequestParam(name = "rowKey") String rk) {
        return new HadoopTableData();
    }

    /**
     * 查询数据
     */
    @ApiOperation(value = "查询数据", notes = "流年·公子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "tableName", value = "HBase表名", required = true, dataType = "String", paramType = RequestParamType.FORM),
            @ApiImplicitParam(name = "rowKey", value = "唯一标识", required = true, dataType = "String", paramType = RequestParamType.FORM)
    })
    @PostMapping(value = "/data/query")
    public HadoopTableData queryDataFromHBase(String tableName, String rowKey) {
        return new HadoopTableData();
    }

    /**
     * 查询数据
     */
    @ApiOperation(value = "查询数据", notes = "流年·公子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "tableName", value = "HBase表名", required = true, dataType = "String", paramType = RequestParamType.PATH),
            @ApiImplicitParam(name = "rowKey", value = "唯一标识", required = true, dataType = "String", paramType = RequestParamType.PATH)
    })
    @GetMapping(value = "/data/var/get/{tableName}/{rowKey}")
    public HadoopTableData getVarDataFromHBase(@PathVariable("tableName") String tn, @PathVariable("rowKey") String rk) {
        return new HadoopTableData();
    }

    /**
     * 查询数据
     */
    @ApiOperation(value = "查询数据", notes = "流年·公子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "model", value = "传入json数据", required = true, dataType = "QueryModel", paramType = RequestParamType.BODY)
    })
    @PostMapping(value = "/data/var/query")
    public HadoopTableData queryVarDataFromHBase(@RequestBody QueryModel model) {
        return new HadoopTableData();
    }
    //endregion

    //region 添加数据

    /**
     * 添加数据
     */
    @ApiOperation(value = "添加数据", notes = "流年·公子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "model", value = "传入json数据", required = true, dataType = "SubmitModel", paramType = RequestParamType.BODY)
    })
    @PostMapping(value = "/data/add")
    public String submitDataForHBase(@RequestBody SubmitModel model) {
        return "successfully";
    }
    //endregion

}
